import Vue from 'vue'
import request from '@/utils/request'

// 请求方法
export default ({ store }) => {
  Vue.prototype.$http = options => {
    const { token } = store.state.user.user || {}
    const { region_code } = store.state.city
    const { headers = {} } = options
    if (token) {
      headers['Authorization'] = `Bearer ${token}`
    }
    headers['X-Halo-Region'] = region_code
    headers['X-Halo-App'] = 'wedding-web-hotel'
    options.headers = headers
    options.loading = false
    return request(options)
  }
}
